<template>
  <div class="introduce">
    <div
      class="introduce-text"
      :style="{ maxHeight: maxHeights }"
      v-html="list.giDetails"
      ref="introduces"
    ></div>

    <div class="changLabe" @click="changLabe" v-if="inDisplay">
      {{ labe[index].name }}
      <img :src="labe[index].img" alt="" />
    </div>

    <div class="jieshaos">
      <div class="jies-labe">
        <span class="jieshaosone"></span>
        <span> 游戏简介</span>
      </div>
      <div
        class="jiesnei"
        v-html="list.giTitle"
        ref="jianjie"
        :style="{ maxHeight: maxHeights2 }"
      ></div>
    </div>
    <div class="changLabe" @click="changLabe2" v-if="jianDisplay">
      {{ labe[index2].name }}
      <img :src="labe[index2].img" alt="" />
    </div>

    <div class="xiangqing">
      <div class="jies-labe2">
        <span></span>
        <span> 详细信息</span>
      </div>
      <div class="jiespei">
        <div>
          <span class="changColor">文件大小：</span>
          <span v-if="list.gjSize != ''">{{ list.gjSize }}</span>
          <span v-else> 暂无数据 </span>
        </div>
        <div>
          <span class="changColor">当前版本：</span>
          <span v-if="list.gjEdition != ''">{{ list.gjEdition }}</span>
          <span v-else> 暂无数据 </span>
        </div>
        <div>
          <span class="changColor">开发厂商：</span>
          <span v-if="list.gjDeveloper != ''">{{ list.gjDeveloper }}</span>
          <span v-else> 暂无数据 </span>
        </div>
        <div>
          <span class="changColor">运营厂商：</span>
          <span v-if="list.gjOperator != ''">{{ list.gjOperator }}</span>
          <span v-else> 暂无数据 </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { showGameMessage } from "../../../../network/showGame";

export default {
  name: "Introduce",
  data() {
    return {
      labe: [
        { name: "展开", img: "http://qiangwu.top/xia.svg" },
        { name: "收起", img: "http://qiangwu.top/shang.svg" },
      ],
      maxHeights: "200px",
      maxHeights2: "220px",
      index: 0,
      index2: 0,
      times: 0,
      list: "",
      inDisplay: false,
      jianDisplay: false,
    };
  },
  created() {
    this.getId();
  },
  updated() {
    if (this.$refs.jianjie.scrollHeight > 200) {
      this.jianDisplay = true;
    }
    if (this.$refs.introduces.scrollHeight > 200) {
      this.inDisplay = true;
    }
  },
  methods: {
    changLabe() {
      if (this.index == 0) {
        this.index = 1;
        this.maxHeights = this.$refs.introduces.scrollHeight + "px";
      } else if (this.index == 1) {
        this.maxHeights = "200px";
        this.index = 0;
      }
    },

    changLabe2() {
      if (this.index2 == 0) {
        this.index2 = 1;
        this.maxHeights2 = this.$refs.jianjie.scrollHeight + "px";
      } else if (this.index2 == 1) {
        this.maxHeights2 = "220px";
        this.index2 = 0;
      }
    },
    getId() {
      let gid = window.location.pathname.split("/")[2];
      showGameMessage(gid, this.$Cookie.get("userid")).then((res) => {
        this.list = res.data.data;
      });
    },
  },
};
</script>

<style>
.introduce {
  width: 80%;
  margin: 0 auto;
  margin-bottom: 0.8rem;
}

.introduce-text {
  font-size: 0.1rem;
  overflow: hidden;
  line-height: 0.35rem;
  transition: all 0.8s;
}

.changLabe {
  font-size: 0.1rem;
  color: rgb(35, 173, 229);
  cursor: pointer;
  margin-top: 0.05rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.changLabe img {
  width: 0.13rem;
  height: 0.13rem;
}

.jieshaos {
  margin-top: 0.5rem;
}

.jies-labe {
  display: flex;
  align-items: center;
}

.jieshaosone {
  display: inline-block;
  width: 0.05rem;
  height: 0.15rem;
  border-radius: 10px;
  background-color: rgb(35, 173, 229);
}

.jieshaos span:nth-child(2) {
  display: inline-block;
  font-size: 0.12rem;
  line-height: 0.15rem;
  margin-left: 0.1rem;
}

.jiesnei {
  margin-top: 0.1rem;
  font-size: 0.1rem;
  line-height: 0.18rem;
  overflow: hidden;
  transition: all 0.5s;
}

.jies-labe2 {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgb(185, 184, 183);
  margin-top: 0.8rem;
}

.jies-labe2 span:nth-child(1) {
  font-size: 0.1rem;
  display: inline-block;
  width: 0.05rem;
  height: 0.15rem;
  border-radius: 10px;
  background-color: rgb(35, 173, 229);
}

.jies-labe2 span:nth-child(2) {
  display: inline-block;
  font-size: 0.12rem;
  line-height: 0.15rem;
  margin-left: 0.1rem;
}

.jiespei {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  flex-wrap: wrap;
}

.jiespei div {
  display: flex;
  width: 50%;
  font-size: 0.1rem;
  border-bottom: 1px solid rgb(211, 210, 209);
  padding: 0.15rem 0 0.15rem 0;
}

.changColor {
  color: rgb(173, 174, 175);
}
</style>